import React, {Component} from 'react'
import {Tabs} from 'antd';
import {messages} from "share/common";
import {connect} from 'react-redux';

const TabPane = Tabs.TabPane;
import BaseInfo from './plane-tabs/base-info'
import FlightInfo from './plane-tabs/flight-info'
import AircrewInfo from './plane-tabs/aircrew-info'
import RefundTicketInfo from './plane-tabs/refund-ticket-info'
import TripInfo from './plane-tabs/trip-info'
import OrderCenterServer from 'containers/supplier-management/order-center/order-center-server'

class DetailPlane extends Component {
  constructor(props) {
    super(props);
    this.params = {
      channel: "hly-admin",
      vendorName: "ctrip",
      companyOID: props.company.companyOID,
    }
    this.state = {
      detailData: {},// 详情数据
      baseInfo: {},
      flightInfo: [],
      aircrewInfo: [],
      refundTicketInfo: [],
      tripInfo: [],
    }
  }

  componentDidMount() {
    this.params.orderId = this.props.params.recordId;
    OrderCenterServer(this).getPlaneDetail(this.params).then(res => {
      const {airOrderInfoEntityVOs} = res.data;
      this.setState({
        detailData: airOrderInfoEntityVOs,
        baseInfo: airOrderInfoEntityVOs.airBaseOrder,
        flightInfo: airOrderInfoEntityVOs.airFlightInfo,
        aircrewInfo: airOrderInfoEntityVOs.airPassengerInfo,
        refundTicketInfo: airOrderInfoEntityVOs.airRefundInfo,
        tripInfo: airOrderInfoEntityVOs.airTicketPrint,
      })
    })
  }

  render() {
    const {baseInfo, flightInfo, aircrewInfo, refundTicketInfo, tripInfo} = this.state;
    return (
      <div>
        <Tabs>
          <TabPane tab={messages('pre.payment.essential.information')/*基本信息*/} key='1'>
            <BaseInfo data={baseInfo} />
          </TabPane>
          <TabPane tab={messages('my-account.key225')/*航班信息*/} key='2'>
            <FlightInfo data={flightInfo}/>
          </TabPane>
          <TabPane tab={messages('supplier.key309')/*乘机人信息*/} key='3'>
            <AircrewInfo data={aircrewInfo} />
          </TabPane>
          <TabPane tab={messages('supplier.key310')/*退票信息*/} key='4'>
            <RefundTicketInfo data={refundTicketInfo} />
          </TabPane>
          <TabPane tab={messages('supplier.key311')/*行程单信息*/} key='5'>
            <TripInfo data={tripInfo} />
          </TabPane>
        </Tabs>
      </div>
    )
  }
}


function mapStateToProps(state) {
  return {
    company: state.login.company,
  }
}

export default connect(mapStateToProps)(DetailPlane);
